<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Código-Fonte de individual.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Gerado por Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Busca');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Página&nbsp;Principal</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Arquivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Busca" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;de&nbsp;Arquivos</span></a></li>
      <li><a href="globals.html"><span>Arquivos&nbsp;Membros</span></a></li>
    </ul>
  </div>
<h1>individual.h</h1><a href="individual_8h.html">Vá para a documentação deste arquivo.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef INDIVIDUAL_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define INDIVIDUAL_H</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="coordinate_8h.html" title="Arquivo que contêm as definições da classe template coordinate.">coordinate.h</a>&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="definitions_8h.html">definitions.h</a>&quot;</span><span class="comment">//definições básicas/default</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00025"></a>00025 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00026"></a>00026 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty = GAtype,<span class="keyword">typename</span> _realTy = GAreal_type&gt; <span class="keyword">class </span><a class="code" href="classindividual.html">individual</a>;
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00035"></a>00035 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00036"></a>00036 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00037"></a><a class="code" href="classindividual.html">00037</a> <span class="keyword">class </span><a class="code" href="classindividual.html">individual</a>
<a name="l00038"></a>00038 {
<a name="l00039"></a>00039   <span class="keyword">public</span>:
<a name="l00040"></a>00040     
<a name="l00041"></a>00041     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00042"></a>00042 <span class="comment">     * --- Algumas definições básicas da classe                        *</span>
<a name="l00043"></a>00043 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00049"></a>00049     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00050"></a><a class="code" href="classindividual.html#a1e5daa9df67df2ce845387ea20c7111e">00050</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;coordinate&lt;_ty,_realTy&gt;*&gt; <a class="code" href="classindividual.html#a1e5daa9df67df2ce845387ea20c7111e">posTy_</a>;
<a name="l00051"></a>00051 
<a name="l00052"></a>00052     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00056"></a>00056     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00057"></a><a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">00057</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;coordinate&lt;_ty,_realTy&gt;*&gt;::iterator <a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">it_</a>;
<a name="l00058"></a>00058 
<a name="l00059"></a>00059     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00063"></a>00063     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00064"></a><a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">00064</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;coordinate&lt;_ty,_realTy&gt;*&gt;::const_iterator <a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">const_it_</a>;
<a name="l00065"></a>00065     
<a name="l00066"></a>00066     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00067"></a>00067 <span class="comment">     * --- Construtores/Destrutores                                    *</span>
<a name="l00068"></a>00068 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00078"></a>00078     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00079"></a>00079     <a class="code" href="classindividual.html#af3455065daf6ab90fdb5c3e6347e453f">individual</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; <span class="keywordtype">id</span>,
<a name="l00080"></a>00080                 <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; dimension = def::individual::dimension,
<a name="l00081"></a>00081                 <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; size = def::individual::size);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00089"></a>00089     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00090"></a>00090     <a class="code" href="classindividual.html#af3455065daf6ab90fdb5c3e6347e453f">individual</a> (<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>);
<a name="l00091"></a>00091                 
<a name="l00092"></a>00092     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00096"></a>00096     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00097"></a>00097     <a class="code" href="classindividual.html#a987acf66924e969f29e3091faf6776b3">~individual</a> (<span class="keywordtype">void</span>);
<a name="l00098"></a>00098     
<a name="l00099"></a>00099     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00100"></a>00100 <span class="comment">     * --- Métodos de interface (get/set)                              *</span>
<a name="l00101"></a>00101 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00109"></a>00109     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00110"></a><a class="code" href="classindividual.html#adf23ea4763b162d8e84ee53765775697">00110</a>     <span class="keyword">const</span> _realTy&amp; <a class="code" href="classindividual.html#adf23ea4763b162d8e84ee53765775697">GetValue</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _val;}
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00118"></a>00118     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00119"></a><a class="code" href="classindividual.html#a906863b234c66ce3a45cab44c85ef385">00119</a>     <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a906863b234c66ce3a45cab44c85ef385">SetValue</a> (<span class="keyword">const</span> _realTy&amp; new_val) {_val = new_val;}
<a name="l00120"></a>00120     
<a name="l00121"></a>00121     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00127"></a>00127     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00128"></a><a class="code" href="classindividual.html#ad9f03da405f7f069cbafd11387fbf5f9">00128</a>     <span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* <a class="code" href="classindividual.html#ad9f03da405f7f069cbafd11387fbf5f9">GetPair</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _pair;}
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00136"></a>00136     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00137"></a><a class="code" href="classindividual.html#a57a124a83b28f8af06fa2e5dbcf30c55">00137</a>     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* <a class="code" href="classindividual.html#a57a124a83b28f8af06fa2e5dbcf30c55">GetPair</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _pair;}
<a name="l00138"></a>00138 
<a name="l00139"></a>00139     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00145"></a>00145     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00146"></a><a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">00146</a>     <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">SetPair</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* new_pair) {_pair = new_pair;}
<a name="l00147"></a>00147     
<a name="l00148"></a>00148     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00154"></a>00154     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00155"></a><a class="code" href="classindividual.html#a061ed50343d97420486e74d49e38a96f">00155</a>     <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; <a class="code" href="classindividual.html#a061ed50343d97420486e74d49e38a96f">GetSize</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _size;}
<a name="l00156"></a>00156     
<a name="l00157"></a>00157     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00163"></a>00163     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00164"></a><a class="code" href="classindividual.html#a2142383da99c87d1f2dac7fccd4565d8">00164</a>     <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; <a class="code" href="classindividual.html#a2142383da99c87d1f2dac7fccd4565d8">GetDimension</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _dimension;}
<a name="l00165"></a>00165     
<a name="l00166"></a>00166     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00172"></a>00172     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00173"></a><a class="code" href="classindividual.html#aec666131664fc884367d321cde07a586">00173</a>     <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; <a class="code" href="classindividual.html#aec666131664fc884367d321cde07a586">GetID</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _identifier;}
<a name="l00174"></a>00174 
<a name="l00175"></a>00175     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00181"></a>00181     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00182"></a><a class="code" href="classindividual.html#aa9650e911651d6656cbd44f0d9344aaf">00182</a>     <span class="keywordtype">void</span> <a class="code" href="classindividual.html#aa9650e911651d6656cbd44f0d9344aaf">SetID</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; new_id) {_identifier = new_id;}
<a name="l00183"></a>00183 
<a name="l00184"></a>00184     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00190"></a>00190     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00191"></a><a class="code" href="classindividual.html#aacc10fcba3051c1b1913afe924c8f293">00191</a>     <a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">const_it_</a> <a class="code" href="classindividual.html#aacc10fcba3051c1b1913afe924c8f293">begin</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _position.begin();}
<a name="l00192"></a>00192 
<a name="l00193"></a>00193     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00199"></a>00199     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00200"></a><a class="code" href="classindividual.html#af2c60e6a02eae91c9f1b419a11067bdb">00200</a>     <a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">const_it_</a> <a class="code" href="classindividual.html#af2c60e6a02eae91c9f1b419a11067bdb">end</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _position.end();}
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00208"></a>00208     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00209"></a><a class="code" href="classindividual.html#a593da2dd173a84dd3dec95fd505cc348">00209</a>     <a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">it_</a> <a class="code" href="classindividual.html#a593da2dd173a84dd3dec95fd505cc348">begin</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _position.begin();}
<a name="l00210"></a>00210 
<a name="l00211"></a>00211     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00217"></a>00217     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00218"></a><a class="code" href="classindividual.html#a101b20b621ef6cf681ba210247c937d5">00218</a>     <a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">it_</a> <a class="code" href="classindividual.html#a101b20b621ef6cf681ba210247c937d5">end</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _position.end();}
<a name="l00219"></a>00219     
<a name="l00220"></a>00220     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00228"></a>00228     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00229"></a>00229     <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#a06553b7f9e7ae18920b6956d68aec8f9">AddCoordinate</a> (<span class="keyword">const</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; new_coord);
<a name="l00230"></a>00230 
<a name="l00231"></a>00231     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00237"></a>00237     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00238"></a>00238     std::vector&lt;_realTy&gt; <a class="code" href="classindividual.html#a23ee0230af928473dfb38c8d2f03a6d8">GetRealPosition</a> (<span class="keywordtype">void</span>) <span class="keyword">const</span>;
<a name="l00239"></a>00239     
<a name="l00240"></a>00240     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00244"></a>00244     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00245"></a>00245     <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a64d3b068c2c4e652a93051ab261b06eb">GeneratePosition</a> (<span class="keywordtype">void</span>);
<a name="l00246"></a>00246 
<a name="l00247"></a>00247     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00251"></a>00251     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00252"></a><a class="code" href="classindividual.html#a19b73804838e239adf7eb78ac7d4495c">00252</a>     <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a19b73804838e239adf7eb78ac7d4495c">PrintRealPosition</a> (<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00253"></a>00253 <span class="keyword">    </span>{
<a name="l00254"></a>00254       std::vector&lt;_realTy&gt; real = <a class="code" href="classindividual.html#a23ee0230af928473dfb38c8d2f03a6d8">GetRealPosition</a>();
<a name="l00255"></a>00255       <span class="keywordflow">for</span>(<span class="keyword">typename</span> std::vector&lt;_realTy&gt;::iterator it = real.begin(); it != real.end(); ++it)
<a name="l00256"></a>00256         std::cout &lt;&lt; *it &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; std::endl;
<a name="l00257"></a>00257     }
<a name="l00258"></a>00258     
<a name="l00259"></a>00259     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00260"></a>00260 <span class="comment">     * --- Sobrecarga de operadores                                    *</span>
<a name="l00261"></a>00261 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00262"></a>00262 
<a name="l00263"></a>00263     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00271"></a>00271     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00272"></a><a class="code" href="classindividual.html#a62c3d8ac9655e7cc94bd290013a7fb9c">00272</a>     <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; <a class="code" href="classindividual.html#a62c3d8ac9655e7cc94bd290013a7fb9c">operator [] </a>(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos) {<span class="keywordflow">if</span>((pos &gt;= 0) &amp;&amp; (pos&lt;_dimension)) <span class="keywordflow">return</span> *_position[pos];}
<a name="l00273"></a>00273     
<a name="l00274"></a>00274     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00282"></a>00282     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00283"></a><a class="code" href="classindividual.html#afe28d4eab4c2cc479b00931cc5c51d1b">00283</a>     <span class="keyword">const</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; <a class="code" href="classindividual.html#a62c3d8ac9655e7cc94bd290013a7fb9c">operator [] </a>(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos)<span class="keyword"> const </span>{<span class="keywordflow">if</span>((pos &gt;= 0) &amp;&amp; (pos&lt;_dimension)) <span class="keywordflow">return</span> *_position[pos];}
<a name="l00284"></a>00284     
<a name="l00285"></a>00285     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00293"></a>00293     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00294"></a><a class="code" href="classindividual.html#aec35be09dd951d52d794adf07f18f555">00294</a>     <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#aec35be09dd951d52d794adf07f18f555">operator == </a>(<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _val == <span class="keywordtype">id</span>.GetValue();}
<a name="l00295"></a>00295     
<a name="l00296"></a>00296     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00304"></a>00304     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00305"></a><a class="code" href="classindividual.html#a354f288f25fd01c842c91eba334cbc62">00305</a>     <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#a354f288f25fd01c842c91eba334cbc62">operator != </a>(<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _val != <span class="keywordtype">id</span>.GetValue();}
<a name="l00306"></a>00306     
<a name="l00307"></a>00307     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00315"></a>00315     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00316"></a><a class="code" href="classindividual.html#a33af2ec8a3a483ddd5e188959a20f22b">00316</a>     <span class="keywordtype">bool</span> operator &lt; (const individual&lt;_ty,_realTy&gt;&amp; id) <span class="keyword">const</span> {<span class="keywordflow">return</span> _val &lt; <span class="keywordtype">id</span>.GetValue();}
<a name="l00317"></a>00317     
<a name="l00318"></a>00318     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00326"></a>00326     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00327"></a><a class="code" href="classindividual.html#a059f721458f46910431c30d5c7f8b83d">00327</a>     <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#a059f721458f46910431c30d5c7f8b83d">operator &gt; </a>(<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _val &gt; <span class="keywordtype">id</span>.GetValue();}
<a name="l00328"></a>00328     
<a name="l00329"></a>00329     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00337"></a>00337     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00338"></a><a class="code" href="classindividual.html#a2116152c25706d6e5eef761f8b516cbe">00338</a>     <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#a2116152c25706d6e5eef761f8b516cbe">operator &gt;= </a>(<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _val &gt;= <span class="keywordtype">id</span>.GetValue();}
<a name="l00339"></a>00339     
<a name="l00340"></a>00340     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00348"></a>00348     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00349"></a><a class="code" href="classindividual.html#a5fd9597a7c5dc2308535236c314d85e6">00349</a>     <span class="keywordtype">bool</span> operator &lt;= (const individual&lt;_ty,_realTy&gt;&amp; id) <span class="keyword">const</span> {<span class="keywordflow">return</span> _val &lt;= <span class="keywordtype">id</span>.GetValue();}
<a name="l00350"></a>00350     
<a name="l00351"></a>00351     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00362"></a>00362     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00363"></a>00363     <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; <span class="keyword">friend</span>
<a name="l00364"></a>00364     std::istream&amp; <a class="code" href="classindividual.html#a11c97e7fa3954c61cc91282d96d1ae2d">operator &gt;&gt; </a>(std::istream&amp; is, <a class="code" href="classindividual.html">individual&lt;T,U&gt;</a>&amp; <span class="keywordtype">id</span>);
<a name="l00365"></a>00365     
<a name="l00366"></a>00366     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00377"></a>00377     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00378"></a>00378     <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; <span class="keyword">friend</span>
<a name="l00379"></a>00379     std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const individual&lt;T,U&gt;&amp; id);
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00382"></a>00382 <span class="comment">     * --- Métodos estáticos                                           *</span>
<a name="l00383"></a>00383 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00384"></a>00384 
<a name="l00385"></a>00385     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00392"></a>00392     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00393"></a><a class="code" href="classindividual.html#a848c15d022ac9f2b446b45d7fae7ddd0">00393</a>     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a848c15d022ac9f2b446b45d7fae7ddd0">MakePair</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; id_1,<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; id_2) {id_1.<a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">SetPair</a>(&amp;id_2);id_2.<a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">SetPair</a>(&amp;id_1);}
<a name="l00394"></a>00394 
<a name="l00395"></a>00395     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00402"></a>00402     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00403"></a><a class="code" href="classindividual.html#a3f064fc3cf1612ef6cd2ffda4cb7610c">00403</a>     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a3f064fc3cf1612ef6cd2ffda4cb7610c">SeparetePair</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; id_1,<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; id_2) {id_1.<a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">SetPair</a>(NULL);id_2.<a class="code" href="classindividual.html#a07dd69312bd76a2046ca3331b769023d">SetPair</a>(NULL);}
<a name="l00404"></a>00404 
<a name="l00405"></a>00405   <span class="keyword">private</span>:
<a name="l00406"></a>00406     
<a name="l00407"></a>00407     <span class="keywordtype">int</span> _identifier;<span class="comment">//identificador, que identifica o indivíduo</span>
<a name="l00408"></a>00408     <span class="keywordtype">int</span> _size;<span class="comment">//tamanho em bits da codificação</span>
<a name="l00409"></a>00409     <span class="keywordtype">int</span> _dimension;<span class="comment">//número de graus de liberdade do problema</span>
<a name="l00410"></a>00410     <a class="code" href="classindividual.html#a1e5daa9df67df2ce845387ea20c7111e">posTy_</a> _position;<span class="comment">//vetor com as coordenadas do indivíduo</span>
<a name="l00411"></a>00411     _realTy _val;<span class="comment">//valor da função objetivo no ponto em que o indivíduo se encontra</span>
<a name="l00412"></a>00412     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* _pair;<span class="comment">//parceiro do indivíduo em um futuro cruzamento</span>
<a name="l00413"></a>00413     
<a name="l00414"></a>00414     
<a name="l00415"></a>00415 };
<a name="l00416"></a>00416 
<a name="l00417"></a>00417 <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00418"></a>00418 <span class="comment"> * --- Construtores/Destrutores                                    *</span>
<a name="l00419"></a>00419 <span class="comment"> * --------------------------------------------------------------- */</span>
<a name="l00420"></a>00420 
<a name="l00421"></a>00421 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00422"></a><a class="code" href="classindividual.html#af3455065daf6ab90fdb5c3e6347e453f">00422</a> <a class="code" href="classindividual.html#af3455065daf6ab90fdb5c3e6347e453f">individual&lt;_ty,_realTy&gt;::individual</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; dimension, <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; size )
<a name="l00423"></a>00423 :_size(size),_dimension(dimension),_identifier(id)
<a name="l00424"></a>00424 {
<a name="l00425"></a>00425   <span class="comment">//incialização das variáveis</span>
<a name="l00426"></a>00426   this-&gt;_pair = NULL;
<a name="l00427"></a>00427   this-&gt;_val = 0;
<a name="l00428"></a>00428   
<a name="l00429"></a>00429   <span class="keywordtype">int</span> indice = 0;
<a name="l00430"></a>00430   
<a name="l00431"></a>00431   <span class="keywordflow">do</span>
<a name="l00432"></a>00432   {
<a name="l00433"></a>00433     _position.push_back(<span class="keyword">new</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>(indice));
<a name="l00434"></a>00434   } <span class="keywordflow">while</span> (++indice != _dimension);
<a name="l00435"></a>00435   
<a name="l00436"></a>00436 }
<a name="l00437"></a>00437 
<a name="l00438"></a>00438 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00439"></a><a class="code" href="classindividual.html#ab73b6268c2159515fc0bd845fbbbb13c">00439</a> <a class="code" href="classindividual.html#af3455065daf6ab90fdb5c3e6347e453f">individual&lt;_ty,_realTy&gt;::individual</a> (<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span>)
<a name="l00440"></a>00440 {
<a name="l00441"></a>00441   this-&gt;_pair = NULL;<span class="comment">//por opção o par não é copiado</span>
<a name="l00442"></a>00442   this-&gt;_val = <span class="keywordtype">id</span>._val;
<a name="l00443"></a>00443   this-&gt;_size = <span class="keywordtype">id</span>._size;
<a name="l00444"></a>00444   this-&gt;_dimension = <span class="keywordtype">id</span>._dimension;
<a name="l00445"></a>00445   this-&gt;_identifier = <span class="keywordtype">id</span>._identifier;
<a name="l00446"></a>00446 
<a name="l00447"></a>00447   <span class="keywordflow">for</span> (<a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">const_it_</a> it = <span class="keywordtype">id</span>._position.begin(); it != <span class="keywordtype">id</span>._position.end(); ++it)
<a name="l00448"></a>00448   {
<a name="l00449"></a>00449     <span class="comment">//prestar atenção no pc_cte da classe coordinate</span>
<a name="l00450"></a>00450     this-&gt;_position.push_back(<span class="keyword">new</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>((*it)-&gt;GetIndice(),(*it)-&gt;GetSize(),(*it)-&gt;GetPrecision(),(*it)-&gt;GetMax(),(*it)-&gt;GetMin()));
<a name="l00451"></a>00451     (this-&gt;_position.back())-&gt;<a class="code" href="classindividual.html#a906863b234c66ce3a45cab44c85ef385">SetValue</a>((*it)-&gt;GetValue());
<a name="l00452"></a>00452   }
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454 
<a name="l00455"></a>00455 
<a name="l00456"></a>00456 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00457"></a><a class="code" href="classindividual.html#a987acf66924e969f29e3091faf6776b3">00457</a> <a class="code" href="classindividual.html#a987acf66924e969f29e3091faf6776b3">individual&lt;_ty,_realTy&gt;::~individual</a> (<span class="keywordtype">void</span>)
<a name="l00458"></a>00458 {
<a name="l00459"></a>00459   <span class="keywordflow">for</span> ( <a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">it_</a> it = _position.begin(); it != _position.end(); ++it )
<a name="l00460"></a>00460     <span class="keyword">delete</span> *it;
<a name="l00461"></a>00461 }
<a name="l00462"></a>00462 
<a name="l00463"></a>00463 <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00464"></a>00464 <span class="comment"> * --- Métodos públicos                                            *</span>
<a name="l00465"></a>00465 <span class="comment"> * --------------------------------------------------------------- */</span>
<a name="l00466"></a>00466 
<a name="l00467"></a>00467 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00468"></a><a class="code" href="classindividual.html#a64d3b068c2c4e652a93051ab261b06eb">00468</a> <span class="keywordtype">void</span> <a class="code" href="classindividual.html#a64d3b068c2c4e652a93051ab261b06eb">individual&lt;_ty,_realTy&gt;::GeneratePosition</a> (<span class="keywordtype">void</span>)
<a name="l00469"></a>00469 {
<a name="l00470"></a>00470   <span class="keywordflow">for</span> (<a class="code" href="classindividual.html#a366746f769614c9cc31b42da59525c6b">it_</a> it = _position.begin(); it != _position.end(); ++it)
<a name="l00471"></a>00471       (*it)-&gt;GenerateCoordinate();
<a name="l00472"></a>00472 }
<a name="l00473"></a>00473 
<a name="l00474"></a>00474 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00475"></a><a class="code" href="classindividual.html#a23ee0230af928473dfb38c8d2f03a6d8">00475</a> std::vector&lt;_realTy&gt; <a class="code" href="classindividual.html#a23ee0230af928473dfb38c8d2f03a6d8">individual&lt;_ty,_realTy&gt;::GetRealPosition</a> (<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00476"></a>00476 <span class="keyword"></span>{
<a name="l00477"></a>00477   std::vector&lt;_realTy&gt; real_pos;
<a name="l00478"></a>00478   <span class="keywordflow">for</span> (<a class="code" href="classindividual.html#adcf0ed63de337fb1511eb795502f6e48">const_it_</a> it = _position.begin(); it != _position.end(); ++it)
<a name="l00479"></a>00479     real_pos.push_back(<a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;::Decode</a>(*(*it)));
<a name="l00480"></a>00480   <span class="keywordflow">return</span> real_pos;
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 
<a name="l00483"></a>00483 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00484"></a><a class="code" href="classindividual.html#a06553b7f9e7ae18920b6956d68aec8f9">00484</a> <span class="keywordtype">bool</span> <a class="code" href="classindividual.html#a06553b7f9e7ae18920b6956d68aec8f9">individual&lt;_ty,_realTy&gt;::AddCoordinate</a> (<span class="keyword">const</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; new_coord)
<a name="l00485"></a>00485 {
<a name="l00486"></a>00486   <span class="comment">//se ainda não preencheu o vetor de posições</span>
<a name="l00487"></a>00487   <span class="keywordflow">if</span> (_dimension &gt; _position.size())
<a name="l00488"></a>00488   {
<a name="l00489"></a>00489     <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>* coo = <span class="keyword">new</span> <a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>();
<a name="l00490"></a>00490     *coo = new_coord;
<a name="l00491"></a>00491     _position.push_back(coo);
<a name="l00492"></a>00492     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00493"></a>00493   }
<a name="l00494"></a>00494   <span class="keywordflow">else</span>
<a name="l00495"></a>00495     <span class="keywordflow">return</span> <span class="keyword">false</span>;<span class="comment">//o vetor já se encontra preenchido</span>
<a name="l00496"></a>00496 
<a name="l00497"></a>00497 }       
<a name="l00498"></a>00498 
<a name="l00499"></a>00499 <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00500"></a>00500 <span class="comment"> * --- Sobrecarga de operadores                                    *</span>
<a name="l00501"></a>00501 <span class="comment"> * --------------------------------------------------------------- */</span>
<a name="l00502"></a>00502 
<a name="l00503"></a>00503 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;
<a name="l00504"></a><a class="code" href="individual_8h.html#a11c97e7fa3954c61cc91282d96d1ae2d">00504</a> std::istream&amp; <a class="code" href="coordinate_8h.html#aacb2e8f6ef327786248a961828b53fa5">operator &gt;&gt; </a>(std::istream&amp; is, <a class="code" href="classindividual.html">individual&lt;T,U&gt;</a>&amp; <span class="keywordtype">id</span>)
<a name="l00505"></a>00505 {
<a name="l00506"></a>00506   <span class="keywordtype">int</span> identifier;
<a name="l00507"></a>00507   is &gt;&gt; <span class="keywordtype">id</span>._identifier;
<a name="l00508"></a>00508   identifier = <span class="keywordtype">id</span>._identifier;
<a name="l00509"></a>00509   U val;
<a name="l00510"></a>00510   is &gt;&gt; <span class="keywordtype">id</span>._val;
<a name="l00511"></a>00511   val = <span class="keywordtype">id</span>._val;
<a name="l00512"></a>00512   <span class="keywordtype">int</span> dimension;
<a name="l00513"></a>00513   is &gt;&gt; <span class="keywordtype">id</span>._dimension;
<a name="l00514"></a>00514   dimension = <span class="keywordtype">id</span>._dimension;
<a name="l00515"></a>00515   
<a name="l00516"></a>00516   <span class="keywordtype">int</span> i = <span class="keywordtype">id</span>._dimension;
<a name="l00517"></a>00517   <span class="keywordflow">while</span> (i--)
<a name="l00518"></a>00518     is &gt;&gt; <span class="keywordtype">id</span>[i];
<a name="l00519"></a>00519   <span class="keywordflow">return</span> is;
<a name="l00520"></a>00520 
<a name="l00521"></a>00521 }
<a name="l00522"></a>00522 
<a name="l00523"></a>00523 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;
<a name="l00524"></a><a class="code" href="individual_8h.html#a90bc9541f07077cb6af916fd8dd2eca2">00524</a> std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const individual&lt;T,U&gt;&amp; id)
<a name="l00525"></a>00525 {
<a name="l00526"></a>00526   os &lt;&lt; <span class="keywordtype">id</span>._identifier &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; <span class="keywordtype">id</span>._val &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; <span class="keywordtype">id</span>._dimension &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
<a name="l00527"></a>00527   <span class="keywordtype">int</span> i = <span class="keywordtype">id</span>._dimension;
<a name="l00528"></a>00528   <span class="keywordflow">while</span>(i--)
<a name="l00529"></a>00529     os &lt;&lt; <span class="keywordtype">id</span>[i] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
<a name="l00530"></a>00530 
<a name="l00531"></a>00531   <span class="keywordflow">return</span> os;
<a name="l00532"></a>00532 }
<a name="l00533"></a>00533 
<a name="l00534"></a>00534 
<a name="l00535"></a>00535 <span class="preprocessor">#endif //INDIVIDUAL_H</span>
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Todos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Arquivos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Funções</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variáveis</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Definições de Tipos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Amigas</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address style="text-align: right;"><small>Gerado em Sat Oct 30 13:47:50 2010 por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
